package org.java.jdk8Stream;

/**
 * @Description TODO
 * @Date 2024/10/8 11:17
 * @Created by 10574
 */
public class ExceptionDemo {
    public static void main(String[] args) {
        System.out.println(getInt1());
    }

    /**
     * 在执行到catch中的return a时，返回执行了finally块，执行完又回去返回30，此时的30是常量30
     */
    public static int getInt1() {
        int a = 10;
        try {
            System.out.println(a / 0);
            a = 20;
        } catch (ArithmeticException e) {
            a = 30;
            return a;
        } finally {
            a = 40;
        }
        return a;
    }
    /**
     * 在执行到catch中的return a时，返回执行了finally块，执行完又回去返回30，此时的30是常量30
     */
    public static int getInt2() {
        int a = 10;
        try {
            System.out.println(a / 0);
            a = 20;
        } catch (ArithmeticException e) {
            a = 30;
            return a;
        } finally {
            a = 40;
            return a;
        }
    }

    public static int getInt3() {
        return 0;
    }
}
